<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="检索名称">
              <a-input placeholder="请输入文件名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="3" :sm="24">
            <a-form-item label="搜索类型" style="width: 170px" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                placeholder="请选择"
                v-model="queryParam.searchType"
              >
                <a-select-option value="1">文件夹</a-select-option>
                <a-select-option value="0">文件</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQueryPic" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div style="margin-top: 30px;"> <!--background-color: #FBFBFB;-->
      测试文件上传： <input type='file' ref="testFile" name='up_bussinessLicenseImage'>
      <a-button type="primary" @click="upload1" icon="upload" :loading="confirmLoading">上传</a-button>

      <a-button type="primary" @click="download1" icon="download" :loading="confirmLoading">下载</a-button>

      <div v-if="dirShow" v-for="file in files" style="width: 140px;height: 140px;float: left;margin: 30px 50px;cursor: pointer;" @dblclick="test(file)">
        <img src="../../../../assets/cqb/directory.png" width="96" height="74" style="float: left;margin-left: 10px;"/>
        <span style="float: left;height: 30px;margin-top: 10px;width: 140px;line-height: 30px;font-size: 15px;">{{file.name}}</span>
      </div>

      <div v-if="fileShow" style="border: 1px solid #E0E0E0;height: 300px;float: left;width: 100%;">
        <div style="width: 100%;height: 25px;background-color: #E0E0E0;">文档列表</div>
        <table style="width: 100%;float: left;">
          <tr><td width="30px">1.</td><td><a href="http://192.168.1.154:18089/ejsimage/images/cqb/69857522655522521456.docx">啤酒厂操作文档.docx</a></td></tr>
        </table>
      </div>
    </div>

    <cqb-project-file-modal ref="modalForm" @ok="modalFormOk"></cqb-project-file-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {httpAction,downloadFile} from '@/api/manage'

  export default {
    name: 'CqbProjectFileListPic',
    mixins:[JeecgListMixin, mixinDevice],
    components: {},
    data () {
      return {
        testFile: '',
        files:[{name: '啤酒厂项目文档'},{name: '电子厂项目文档'},{name: '写字楼项目文档'},{name: '啤酒厂项目文档11'}
          ,{name: '啤酒厂项目文档12'},{name: '啤酒厂项目文档33'},{name: '啤酒厂项目文档44'},{name: '啤酒厂项目文档555'}],
        description: '项目文档表管理页面',
        url: {
          list: "/project/file/cqbProjectFile/list",
        },
        queryParam:{
          name:'',
          searchType: '1'
        },
        dirShow: true,
        fileShow: false,
        dictOptions:{},
        superFieldList:[],
        confirmLoading: false
      }
    },
    created() {},
    computed: {},
    methods: {
      download1(){
        let that = this;
        downloadFile('/uploadFileServer/exportUserWord2', '拆迁办协议文档.docx',{}).then((res) => {
        }).finally(() => {
          that.confirmLoading = false;
          that.close();
        })
      },
      upload1(){
        let that = this;
        that.confirmLoading = true;
        let testFile = this.$refs.testFile.files[0];
        console.log(JSON.stringify(testFile));
        var formData = new FormData();
        formData.append("testFile", testFile);
        formData.append("name", "测试");
        httpAction('/uploadFileServer/uploadFolder', formData, 'post').then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            that.$emit('ok');
          } else {
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
          that.close();
        })
      },
      test(file){
        alert(file.name);
      },
      searchQueryPic(){
       if(this.queryParam.searchType =='1'){
         this.dirShow = true;
         this.fileShow = false;
       }else{
         this.dirShow = false;
         this.fileShow = true;
       }
      },
      initDictConfig(){
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>